package my.binlog;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.bridge.SLF4JBridgeHandler;

import java.io.IOException;

public class Main {

    private static final Logger log = LoggerFactory.getLogger(Main.class);

    // https://blog.csdn.net/m0_37583655/article/details/119148470
    public static void main(String[] args) throws IOException {
        // 使用SLF4J打印JUL日志
        // https://stackoverflow.com/questions/6020545/send-redirect-route-java-util-logging-logger-jul-to-logback-using-slf4j
        SLF4JBridgeHandler.removeHandlersForRootLogger();
        SLF4JBridgeHandler.install();

        MySQLConfig conf = new MySQLConfig("121.41.39.119", 3306, "slave", "42134213");
        // 初始化监听器
        MySQLBinLogListener binLogListener = new MySQLBinLogListener(conf);
        binLogListener.regListener("mini_mall", "mall_goods", item -> {
            log.info("监听逻辑处理");
            log.info(item.toString());
        });
        binLogListener.connect();
    }
}